var MapBuilder = function( tile_set_id, maps_id, tile_set_count ) {
	this.setTileSetId = function( tileSetId ) {
		this.tileSetId_ = tileSetId;
	};

	this.getTileSetId = function() {
		return this.tileSetId_;
	};

	this.setMapsId = function( mapsId ) {
		this.mapsId_ = mapsId;
	};

	this.getMapsId = function() {
		return this.mapsId_;
	};

	this.setTileSetCount = function( tileSetCount ) {
		this.tileSetCount_ = tileSetCount;
	};

	this.getTileSetCount = function() {
		return this.tileSetCount_;
	};

	this.setTabs = function( tabs ) {
		this.tabs_ = tabs;
	};

	this.getTabs = function() {
		return this.tabs_;
	};

	this.setMapLayers = function( mapLayers ) {
		this.mapLayers_ = mapLayers;
	};

	this.getMapLayers = function() {
		return this.mapLayers_;
	};

	this.getLayer = function( id ) {
		return this.getMapLayers()[ id ];
	};

	this.loadTiles = function() {
		this.setMapLayers( [] );
		for ( var i = 0 ; i < this.getTileSetCount() ; i++ ) {
			var id = 'L.' + i;
			this.getMapLayers()[ id ] = new MapLayer( this, id );
		}
	};
	
	this.init = function( tile_set_id, maps_id, tile_set_count ) {
		this.setTileSetId( tile_set_id );
		this.setMapsId( maps_id );
		this.setTileSetCount( tile_set_count ? tile_set_count : 4 );
		this.setTabs( new Tabs( tile_set_id ) );
		this.loadTiles();
	};

	this.init( tile_set_id, maps_id, tile_set_count );

	this.mapClick = function( event ) {
		this.getLayer(
			this.getTabs().getEnabled().getAttribute( 'label' )
		).mapClick( event );
	};




};
